/* 采购退货物料信息行数据 */
import { requestClient } from '#/api/request';

export namespace RtvendorLine {
  export interface Params {
    attr1: null;
  }
  export interface Detail {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    detailId: number;
    lineId: number;
    rtId: number;
    materialStockId: number;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: string;
    unitOfMeasure: string;
    unitName: null;
    quantity: number;
    batchId: number;
    batchCode: string;
    warehouseId: number;
    warehouseCode: string;
    warehouseName: string;
    locationId: number;
    locationCode: string;
    locationName: string;
    areaId: number;
    areaCode: string;
    areaName: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    lineId: number;
    rtId: number;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: null;
    unitOfMeasure: string;
    unitName: string;
    quantityRted: number;
    batchId: null;
    batchCode: null;
    remarks: null;
    details: Detail[];
    attr1: boolean | null | string;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
    rtId: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表及详情
export const getRtvendorLineAndDetailTableList = (
  params: RtvendorLine.GetListParams,
) =>
  requestClient.get<RtvendorLine.GetListReturn>(
    '/mes/wm/rtvendorline/listWithDetail',
    {
      params,
    },
  );
export const getRtvendorLineTableList = (params: RtvendorLine.GetListParams) =>
  requestClient.get<RtvendorLine.GetListReturn>('/mes/wm/rtvendorline/list', {
    params,
  });

// 增加供应商退货行信息
export const addRtvendorLine = (data: RtvendorLine.Row) =>
  requestClient.post<RtvendorLine.GetListReturn>('/mes/wm/rtvendorline', data);

// 删除供应商退货行信息
export const deleteRtvendorLine = (id: string) =>
  requestClient.delete<RtvendorLine.GetListReturn>(
    `/mes/wm/rtvendorline/${id}`,
  );

// 修改供应商退货行设置
export const updateRtvendorLine = (data: RtvendorLine.Row) =>
  requestClient.put<RtvendorLine.GetListReturn>('/mes/wm/rtvendorline', data);
